import pygame
from entity import bullets


class Hero_plane(pygame.sprite.Sprite):

    def __init__(self, bg_size,doc_image1,doc_image2,speed,att_speed,att_dis,blood,power):
        super(Hero_plane, self).__init__()

        self.fly_image1 = pygame.image.load(doc_image1).convert_alpha()
        self.fly_image2 = pygame.image.load(doc_image2).convert_alpha()
        self.die_images = []
        self.rect = self.fly_image1.get_rect()
        self.bg_width, self.bg_height = bg_size[0], bg_size[1]
        self.active = True
        self.invincible = False
        self.mask = pygame.mask.from_surface(self.fly_image1)
        self.rect.left, self.rect.top = \
            (self.bg_width - self.rect.width) / 2, \
            self.bg_height - self.rect.height - 30
        self.bullet = bullets.Bullet1
        self.speed = speed
        self.att_speed = att_speed
        self.att_dis = att_dis
        self.die_index = 0
        self.max_att_pro = 2
        self.blood = self.max_blood =blood
        self.power = self.max_power = power

    def MoveUp(self):
        if self.rect.top <= 0:
            self.rect.top = 0
        else:
            self.rect.top -= self.speed

    def MoveDowm(self):
        if self.rect.bottom <= self.bg_height - 30:
            self.rect.bottom += self.speed


    def MoveLeft(self):
        if (self.rect.right + self.rect.left)/2 > 0:
            self.rect.left -= self.speed

    def MoveRight(self):
        if (self.rect.right + self.rect.left)/2 < self.bg_width:
            self.rect.right += self.speed



class start1_plane(Hero_plane):
    def __init__(self, bg_size):
        Hero_plane.__init__(self,bg_size,"images/me2.png","images/me1.png",5,10,50,6,3)
        self.die_images.extend([
            pygame.image.load("images/me_destroy_1.png").convert_alpha(),
            pygame.image.load("images/me_destroy_2.png").convert_alpha(),
            pygame.image.load("images/me_destroy_3.png").convert_alpha(),
            pygame.image.load("images/me_destroy_4.png").convert_alpha()
        ])
        self.max_speed = 13

class start2_plane(Hero_plane):
    def __init__(self, bg_size):
        Hero_plane.__init__(self,bg_size,"images/plane2_1.png","images/plane2_2.png",5,60,1,3,3)
        self.die_images.extend([
            pygame.image.load("images/plane2_d_1.png").convert_alpha(),
            pygame.image.load("images/plane2_d_2.png").convert_alpha(),
            pygame.image.load("images/plane2_d_3.png").convert_alpha(),
            pygame.image.load("images/plane2_d_4.png").convert_alpha()
        ])
        self.skill_num = 40
        self.max_speed = 15

class start3_plane(Hero_plane):
    def __init__(self, bg_size):
        Hero_plane.__init__(self,bg_size,"images/plane3_1.png","images/plane3_2.png",6,60,40,8,3)
        self.die_images.extend([
            pygame.image.load("images/plane3_d_1.png").convert_alpha(),
            pygame.image.load("images/plane3_d_2.png").convert_alpha(),
            pygame.image.load("images/plane3_d_3.png").convert_alpha(),
            pygame.image.load("images/plane3_d_4.png").convert_alpha()
        ])
        self.max_speed = 10









